// components/orderItem/index.js
const {
  flowRemind,
  flowAuditCreate
} = require('../../api/api')
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    list:{
      type:Array,
      default:[]
    },
    type:{
      type:String,
      value:'index'
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    goto(e){
      const url=e.currentTarget.dataset.url
      wx.navigateTo({
        url: url
      })
    },
    showQuick(e){
      const id=e.currentTarget.dataset.id
      // console.log(id);
      this.data.list.forEach((child)=>{
        child.forEach((item) => {
          if (item.id === id) {
            item.isQuick = true;
          }
        });
      });
      this.setData({
          list:this.data.list
      });
    },
    async gotoA(e){
      const id=e.currentTarget.dataset.id
      const params = {};
      params.documentId = id;
      params.type='flow';
      params.auditState = 1;
      params.trackList = [];//轨迹图
      params.sceneList = [];//现场图
      params.documentList = [];//单据图
      const result = await flowAuditCreate(params);
      console.log("result:"+JSON.stringify(result));
      wx.showToast({
        title: "提交成功!",
        icon: 'none'
      })

      this.triggerEvent('refreshList', {})
      return;
    },
    async gotoR(e){
      const id=e.currentTarget.dataset.id
      const params = {};
      params.documentId = id;
      const result = await flowRemind(params)
      console.log("result:"+JSON.stringify(result));
        wx.showToast({
          title: "已下发提醒！",
          icon: 'none'
        })
        return;
    },
    gotoC(e){
      const id=e.currentTarget.dataset.id
      this.data.list.forEach((child)=>{
        child.forEach((item) => {
          if (item.id === id) {
            item.isQuick = false;
          }
        });
      });
      this.setData({
          list:this.data.list
      });
    }
  }
})
